<?php

/**
 * ConsultingBanks form.
 *
 * @package    eab
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class ConsultingBanksFForm extends BaseFormAdmin
{
	public function configure()
	{
		$tmpAcc = ArrayData::getAccountType();
		$accTypes = array(
				'-1'=> __('option_select', null, 'table_list')
		);
		foreach($tmpAcc as $key=> $val){
			$accTypes[$key] = __($val, null, 'array_data');
		}
		$tmpNick = ArrayData::getNickType();
		$nickTypes = array(
				'-1'=> __('option_select', null, 'table_list')
		);
		foreach($tmpNick as $key=> $val){
			$nickTypes[$key] = __($val, null, 'array_data');
		}
		$tmpBank = ArrayData::getBankingType();
		$bankTypes = array(
				'-1'=> __('option_select', null, 'table_list')
		);
		foreach($tmpBank as $key=> $val){
			$bankTypes[$key] = __($val, null, 'array_data');
		}
		$this->setWidgets(array(
				'banking_type'		=> new sfWidgetFormChoice(array('choices'=>$bankTypes,'expanded'=>false)),
				'nick_type'			=> new sfWidgetFormChoice(array('choices'=>$nickTypes,'expanded'=>false)),
				'account_type'		=> new sfWidgetFormChoice(array('choices'=>$accTypes,'expanded'=>false)),
				'name'				=> new sfWidgetFormInputText(),
				'banking_id'       => new sfWidgetFormDoctrineChoice(array('model' => 'Bankings', 'query' => Doctrine_Query::create()->select('b.id, b.name')->from('Bankings b')->where('b.is_enabled = 1 AND b.is_deleted = 0 AND (b.updated_at IS NULL OR b.updated_at >= b.created_at)'),'multiple' => false, 'add_empty' => __('option_select', null, 'table_list'))),
				'position'         => new sfWidgetFormInputText(),
				'description'      => new sfWidgetFormTextarea(),
				'nick'             => new sfWidgetFormInputText(),
				'tags'             => new sfWidgetFormInputText(),
		));

		$this->setValidators(array(
				'banking_type'		=> new sfValidatorChoice(array('choices'=>array_keys($tmpBank))),
				'nick_type'			=> new sfValidatorChoice(array('choices'=>array_keys($tmpNick))),
				'account_type'		=> new sfValidatorChoice(array('choices'=>array_keys($tmpAcc))),
				'name'				=> new sfValidatorString(array('required' => true),  array('required' =>__('error_name_required',null,'consulting_banks'))),
				'banking_id'       => new sfValidatorDoctrineChoice(array('model' => 'Bankings', 'query' => Doctrine_Query::create()->select('b.id, b.name')->from('Bankings b')->where('b.is_enabled = 1 AND b.is_deleted = 0 AND (b.updated_at IS NULL OR b.updated_at >= b.created_at)'), 'required' => true),array('required'=> 'input banking_id')),
				'position'         => new sfValidatorString(array('max_length' => 255, 'required' => false)),
				'description'      => new sfValidatorString(array('required' => false)),
				'nick'             => new sfValidatorString(array('max_length' => 255, 'required' => false)),
				'tags'             => new sfValidatorString(array('required' => false)),
		));
			
		parent::configure();
		
		
		$this->widgetSchema->setNameFormat('ConsultingBanks[%s]');
		$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
	}

}
